/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entityBeans;

import java.io.Serializable;
import java.util.Date;
import javax.annotation.PostConstruct;
import javax.persistence.Basic;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Temporal;

/**
 *
 * @author h09577
 */
//@Table(name="Message")
//@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
//@DiscriminatorColumn(name="TYPE")
@DiscriminatorValue("message")
@Entity
public class MessageEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date myDate;
    @Basic
    private String content;
    @Basic
    private String messageObject;  
    @Basic
    private boolean isRead;

    public boolean isIsRead() {
        return isRead;
    }

    public void setIsRead(boolean isRead) {
        this.isRead = isRead;
    }
    @ManyToOne
    private UserEntity myAuthor;

    public Date getMyDate() {
        return myDate;
    }

    public void setMyDate(Date myDate) {
        this.myDate = myDate;
    }

    public UserEntity getMyAuthor() {
        return myAuthor;
    }

    public void setMyAuthor(UserEntity myAuthor) {
        this.myAuthor = myAuthor;
    }
    
    @PostConstruct
    public void initialise(){
        
    }
    
    @PrePersist
    private void methodPrePersist() {
        this.setMyDate(new Date());
    }
   
    /**
     * Get the value of messageObject
     *
     * @return the value of messageObject
     */
    public String getMessageObject() {
        return messageObject;
    }

    /**
     * Set the value of messageObject
     *
     * @param messageObject new value of messageObject
     */
    public void setMessageObject(String messageObject) {
        this.messageObject = messageObject;
    }



    /**
     * Get the value of content
     *
     * @return the value of content
     */
    public String getContent() {
        return content;
    }

    /**
     * Set the value of content
     *
     * @param content new value of content
     */
    public void setContent(String content) {
        this.content = content;
    }


    /**
     * Get the value of date
     *
     * @return the value of date
     */
    public Date getDate() {
        return myDate;
    }

    /**
     * Set the value of date
     *
     * @param date new value of date
     */
    public void setDate(Date date) {
        this.myDate = date;
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MessageEntity)) {
            return false;
        }
        MessageEntity other = (MessageEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityBeans.MessageEntity[ id=" + id + " ]";
    }
    
}
